import Vue from 'vue'
import Vuex from 'vuex'
import Storage from '@/utils/ChangeStorage'

Vue.use(Vuex)

const state={
  lang: localStorage.getItem('lang') || 'cn',
  token:Storage.get('token')
}
const mutations= {
  switchLang(state, lang) {
    state.lang = lang
    window.app.$i18n.locale = lang
    localStorage.setItem('lang', lang)
  },
  CHANGE_SETTING: (state, key) => {
    state.theme = key
    // if (state.hasOwnProperty(key)) {
    //   state[key] = value
    // }
  },
  SET_TOKEN: (state, token) => {
    state.token = token
  }

}
const actions= {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  },
}
export default{ state,actions,mutations }